#ifndef NETWORKER_H
#define NETWORKER_H

#include <QNetworkReply>
#include <QObject>


class NetWorker : public QObject
{
    Q_OBJECT
public:
    static NetWorker * instance();
    ~NetWorker();

    QNetworkReply *get(const QString url);
signals:
    void finished(QNetworkReply *reply);
private:
    class Private;
    friend class Private;
    Private *d;
    QNetworkReply *repl;
    QByteArray resultStr;
    QString urlType;
    QHash<QString, QString> urlMap;
    QHash<QString, QString> md5Map;

    explicit NetWorker(QObject *parent = 0);
    NetWorker(const NetWorker &) Q_DECL_EQ_DELETE;
    NetWorker& operator=(NetWorker rhs) Q_DECL_EQ_DELETE;
    void testFinished(QNetworkReply *reply);
    void testRead();
    void quit(QNetworkReply *reply);
    QString getAPIUrl();
    QString getMD5Url();
};

class NetWorker::Private
{
public:
    Private(NetWorker *q) :
        manager(new QNetworkAccessManager(q))
    {}

    QNetworkAccessManager *manager;
};

#endif // NETWORKER_H
